package com.joplus.housekeeper.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.joplus.housekeeper.R;

/**
 * Created by ccm on 2016/11/19 14:58
 */
public class EvaluateMoneyAdapter extends BaseAdapter {
    private Context context;
    private int listenerPosition = 50;
    private LinearLayout ll;
    int[] money = new int[]{5, 10, 20};
    int selectMoney=0;
    public EvaluateMoneyAdapter(Context context) {
        this.context = context;
    }


    public void setSelectMoney(int m) {
        for(int i=0;i<money.length;i++){
            if(m==money[i]){
                this.listenerPosition=i;
                notifyDataSetChanged();
            }
        }


    }


    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(context).inflate(R.layout.item_combo_money, null);
        TextView tv = (TextView) convertView.findViewById(R.id.tv_money);
        ll = (LinearLayout) convertView.findViewById(R.id.ll_money);
        tv.setText("￥" + money[position] + "元");
        if (listenerPosition == position) {
            tv.setTextColor(Color.parseColor("#ffffff"));
            ll.setBackgroundResource(R.drawable.shape_gray);

        }
        return convertView;
    }

    public void changeB(int position) {
        this.listenerPosition = position;
        notifyDataSetChanged();
    }
}
